<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录-X-admin1.1</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
     <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <style>
       #pageInfo a {
		border: 1px solid #a1a1a1;
		padding: 1px 10px;
		background: #FFDDAA;
		width: 1px;
		border-radius: 5px;
		color:blue;
	}
	
	#updataHomeModal,#addHomeModal{
		position:absolute;
		left:40%;
		top:30%;
		z-index:1;
		width:500px;
	}
	#addHomeModal input,#updataHomeModal input{
	width: 300px;
	}
	
	#addRoomModal,#updataRoomModal{
		position:absolute;
		left:40%;
		top:30%;
		z-index:1;
		width:500px;
	}
	
	#addRoomModal input,#updataRoomModal input{
	width: 300px;
	}
	
	
    </style>

<script type="text/javascript">
	$(document).ready(function(){
		//页面一加载就进行ajax请求进行渲染页面
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet",
			data:{op:"findAllHomeMessage",pageNum:"1",pageSize:"3"},
			dataType:"json",
			type:"GET",
			success:function(result,status,xhl){
				console.log(result);
				//调用填充homestay页面头部信息的函数
				fillHomestayPageHead();
				//调用填充信息函数
				fillHomeTableMessage(result.data);
				//调用填充分页信息的函数
				fillPageMessage(result);
			},
			//请求失败时的响应函数
    		error:function(xhr,status,error){
    			console.log("请求失败");
    		}
		});
	});
	
	//homestay页面头部信息填充
	function fillHomestayPageHead(){
		$("#messagePageHead").empty();
		$("#messagePageHead").append(
				"<form class=\"layui-form xbs\" action=\"\" id=\"findHomestayFrom\">"
                +"<div class=\"layui-form-pane\" style=\"text-align: center;\">"
                +"<div class=\"layui-form-item\" style=\"display: inline-block;\">"
                 +" <label class=\"layui-form-label xbs768\">民宿名称</label>"
                  +"<div class=\"layui-input-inline xbs768\">"
                    +"<input class=\"layui-input\" placeholder=\"\" id=\"LAY_demorange_s\" name=\"homeName\">"
                  +"</div>"
                   +"<label class=\"layui-form-label xbs768\">地址</label>"
                   +"<div class=\"layui-input-inline xbs768\">"
                   +"<input class=\"layui-input\" placeholder=\"\" id=\"LAY_demorange_e\" name=\"homeAddress\">"
                   +"</div>"
                   +"<label class=\"layui-form-label xbs768\">风格</label>"
                   +"<div class=\"layui-input-inline xbs768\">"
                   +" <select class=\"layui-input easyui-combobox\" style=\"display: block;\" id=\"selectStyle\" name=\"homeStyle\">"
                   +"<option>选择风格</option>"
                   +"<option>简约</option>"
                   +" <option>复古</option>"
                   +" <option>淡雅</option>"
                   +"</select>"
                   +"</div>"
                   +"<div class=\"layui-input-inline\" style=\"width:80px\">"
              +"<button type=\"button\" class=\"layui-btn\"  lay-submit=\"\" lay-filter=\"sreach\" onclick=\"getHomestayBut()\" id=\"findHomestayBut\"><i class=\"layui-icon\">&#xe615;</i></button>"
                 +" </div>"
               +"</div>"
             +" </div> "
          +"</form>");
	}
	
	//room页面头部信息填充
	function fillRomestayPageHead(homeId){
		//清空之前的内容
		$("#messagePageHead").empty();
		$("#messagePageHead").append(
				"<form class=\"layui-form xbs\" action=\"\" id=\"roomForm\">"
                +"<div class=\"layui-form-pane\" style=\"text-align: center;\">"
                +"<div class=\"layui-form-item\" style=\"display: inline-block;\">"
                 +" <label class=\"layui-form-label xbs768\" id=\"roomIdLableHaveHomeId\" data-homeid=\""+homeId+"\">房间编号</label>"
                  +"<div class=\"layui-input-inline xbs768\">"
                    +"<input class=\"layui-input\" placeholder=\"\" id=\"LAY_demorange_s\" name=\"roomId\">"
                  +"</div>"
                   +"<label class=\"layui-form-label xbs768\">价格</label>"
                   +"<div class=\"layui-input-inline xbs768\">"
                   +"<input class=\"layui-input\" placeholder=\"最低价\" id=\"minPrice\" name=\"minPrice\">"
                   +"</div>"
                   +"<div class=\"layui-input-inline xbs768\">"
                   +"<input class=\"layui-input\" placeholder=\"最高价\" id=\"maxPrice\" name=\"maxPrice\">"
                   +"</div>"
                   +"<label class=\"layui-form-label xbs768\">风格</label>"
                   +"<div class=\"layui-input-inline xbs768\">"
                   +" <select class=\"layui-input \" style=\"display: block;\" id=\"selectStyle\" name=\"styleType\">"
                   +"<option>简约</option>"
                   +" <option>复古</option>"
                   +" <option>淡雅</option>"
                   +"</select>"
                   +"</div>"
                   +"<div class=\"layui-input-inline\" style=\"width:80px\">"
              +" <button type=\"button\" class=\"layui-btn\"  lay-submit=\"\" lay-filter=\"sreach\" onclick=\"getRoomByCondition("+homeId+")\"><i class=\"layui-icon\">&#xe615;</i></button>"
                 +" </div>"
               +"</div>"
             +" </div> "
          +"</form>");
	}
	//填充民宿表格信息函数
	function fillHomeTableMessage(result){
		//清空之间信息
		$("#tableMessage").empty();
		$("#tableMessage").append(
				"<thead>"
                +"<tr>"
                    +"<th>选择</th>"
                    +"<th>ID</th>"
                    +"<th>名称</th>"
                    +"<th>地址</th>"
                    +"<th>电话</th>"
                    +"<th>照片</th>"
                    +"<th>操作</th>"
                +"</tr>"
            +"</thead>");
		for(var i = 0 ;i<result.length;i++){
		$("#tableMessage").append(
            "<tbody>"
               +"<tr>"
                    +"<td><input type=\"checkbox\" value=\""+result[i].homestayId+"\" name=\"delCheckbox\"></td>"
                    +"<td>"+result[i].homestayId+"</td>"
                    +"<td>"+result[i].homestayName+"</td>"
                    +"<td>"+result[i].homestayAddress+"</td>"
                    +"<td>"+result[i].homestayPhone+"</td>"
                    +"<td>"+result[i].homestayPicture+"</td>"
                    +"<td class=\"td-manage\">"
                       +"<a title=\"详情\" href=\"#\" onclick=\"getRoomMessageByHomeId("+result[i].homestayId+")\""
                        +"class=\"ml-5\" style=\"text-decoration:none\">"
                            +"详情<i class=\"layui-icon\">&#xe642;</i>"
                        +"</a>&nbsp&nbsp"
             +"<a style=\"text-decoration:none\""
                       +"href=\"#\" title=\"修改\" onclick=\"updataHome('"
                    		   +result[i].homestayId
                    		   +"','"+result[i].homestayName
                    		   +"','"+result[i].homestayAddress
                    		   +"','"+result[i].homestayPhone
                    		   +"','"+result[i].homestayIntroduce
                    		   +"')\">"
                            +"修改<i class=\"layui-icon\">&#xe631;</i>"
                        +"</a>&nbsp&nbsp"
                       +" <a title=\"删除\" href=\"#\" onclick=\"deleteHomeById("+result[i].homestayId+")\""
                        +"style=\"text-decoration:none\">"
                            +"删除<i class=\"layui-icon\">&#xe640;</i>"
                            +"</a>"
                   +" </td>"
               +" </tr>"
            +"</tbody>");
		}
	}
	
	//填充指定民宿下的所有房间信息
	function fillRomeTableMessage(result){
		//填充信息之前先清空之前的分页信息
		$("#pageInfo").empty();
		//清空之前信息
		$("#tableMessage").empty();
		$("#tableMessage").append(
				"<thead>"
                +"<tr>"
                    +"<th>选择</th>"
                    +"<th>ID</th>"
                    +"<th>状态</th>"
                    +"<th>风格</th>"
                    +"<th>价格</th>"
                    +"<th>照片</th>"
                    +"<th>操作</th>"
                +"</tr>"
            +"</thead>");
		for(var i = 0 ;i<result.length;i++){
		$("#tableMessage").append(
            "<tbody>"
               +"<tr>"
                    +"<td><input type=\"checkbox\" value=\""+result[i].roomId+"\" name=\"delCheckbox\"></td>"
                    +"<td>"+result[i].roomId+"</td>"
                    +"<td>"+result[i].roomState+"</td>"
                    +"<td>"+result[i].styleType+"</td>"
                    +"<td>"+result[i].roomPrice+"</td>"
                    +"<td>"+result[i].roomPicture+"</td>"
                    +"<td class=\"td-manage\">"
             +"<a href=\"#\" style=\"text-decoration:none\"  onclick=\"updateRomeMessageById('"
            		 +result[i].roomId
            		 +"','"+result[i].roomState
            		 +"','"+result[i].styleType
            		 +"','"+result[i].roomPrice
            		 +"')\""
                       +"href=\"#\" title=\"修改\">"
                            +"修改<i class=\"layui-icon\">&#xe631;</i>"
                        +"</a>&nbsp&nbsp"
                       +" <a title=\"删除\" href=\"#\" onclick=\"deleteRomeById("+result[i].roomId+")\""
                        +"style=\"text-decoration:none\">"
                            +"删除<i class=\"layui-icon\">&#xe640;</i>"
                            +"</a>"
                   +" </td>"
               +" </tr>"
            +"</tbody>");
		}
	}
	//详情的点击事件回调函数
	function getRoomMessageByHomeId(homestayId){
		//设置返回上一级按钮可见
		$("#backParent").css("display","inline-block");
		//点击详情时对页面提示信息做修改为1
		 $("#tipMessage").val("1");
		//获取页面条件
		var fromData = $("#findHomestayFrom").serialize();
		//获取当前页信息
		var pageNum  = $("#pageInfoTip").data("pagenum");
		//将页面提示放在隐藏框中
		 $("#tipConditionMessage").val(fromData);
		 $("#tipPageMessage").val(pageNum);
		//点击详情后发送ajax请求得到该民宿下的所有房间
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet",
			data:{"op":"findAllRomeByHomeId",homestayId:homestayId},
			dataType:"json",
			type:"GET",
			success:function(result,status,xhl){
				console.log(result);
				//调用填充房间页面头部的方法
				fillRomestayPageHead(homestayId)
				//调用填充信息函数
				fillRomeTableMessage(result);
			},
			//请求失败时的响应函数
    		error:function(xhr,status,error){
    			console.log("请求失败");
    		}
		});
	}
	
	//包装一个ajax请求函数进行分页请求
	function sendAjax(pageNum){
		//表单数据不带文件的ajax请求
	  	  var fromData = $("#findHomestayFrom").serialize();
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=pageHomeMessage&pageNum="+pageNum+"&pageSize=3",
			type:"GET",
			data:fromData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充信息函数
				fillHomeTableMessage(result.data);
				//调用渲染分页信息函数
				fillPageMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	}
	
	//渲染分页信息函数
	function fillPageMessage(result){
		//填充信息之前先清空之前的分页信息
		$("#pageInfo").empty();
		//进行渲染分页信息
		$("#pageInfo").append("<span id=\"pageInfoTip\" data-pagenum=\""+
				result.pageNum+"\" data-pagesize=\""+
				result.pageSize+"\" data-pagetotal=\""+
				result.total+"\" data-pagepages=\""+
				result.pages+"\">每页"+result.pageSize+"条共"+result.total+"条第"+result.pageNum+"/"+result.pages+"页</span>"
				    +"<a href=\"#\" tabindex=\"0\" class=\"first \""
					+"id=\"firstPage\" onclick=\"fristPage()\">首页</a><a href=\"#\" tabindex=\"0\""
					+"class=\"previous \""
					+"id=\"previousPage\" onclick=\"previousPage()\">上一页</a><span>");
		for(var i = 1;i<=result.pages;i++){
			$("#pageInfo").append("<a href=\"#\" tabindex=\"0\" class=\"\" onclick=\"doPaging('"+i+"')\">"+i+"</a>");
		}
		$("#pageInfo").append("</span><a href=\"#\" tabindex=\"0\" class=\"next \""
					+"id=\"nextPage\" onclick=\"nextPage()\">下一页</a><a href=\"#\" tabindex=\"0\""
					+"class=\"last \""
					+"id=\"lastPage\" onclick=\"lastPage()\">尾页</a>"
					+"<span>总共<label tabindex=\"0\" class=\"\" id=\"allPage\">"+result.pages+"</label>页</span>");
		
	};
	

	//对页码做点击事件
	function doPaging(pageNum){
		sendAjax(pageNum);
	};
	//对最后一页做点击事件
	function lastPage(){
		var pageNum = $("#allPage").text();
		sendAjax(pageNum);
	};
	
	//对首页页做点击事件
	function fristPage(){
		sendAjax(1);
	};
	//对点击下一页时做回调函数
	 function nextPage(){
		//获取当前页码值
		var pageNum  = $("#pageInfoTip").data("pagenum");
		var pages = $("#pageInfoTip").data("pagepages");
		if(pageNum==pages){
			//如果当前页码为最后一页，则设置下一页不可用
			$("#nextPage").css("disabled",true);
		}else{
			$("#nextPage").css("disabled",false);
			sendAjax(pageNum+1);
		}
		
	}; 
	//对点击上一页做回调函数
	 function previousPage(){
		//获取当前页码值
		var pageNum  = $("#pageInfoTip").data("pagenum");
		if(pageNum==1){
			$("#previousPage").css("disabled",true);
		}else{
			$("#previousPage").css("disabled",false);
			sendAjax(pageNum-1);
		}
	}; 
	//对民宿管理的搜索按钮做点击事件
	function getHomestayBut(){
		//请求ajax
		sendAjax(1);
	};
	
	//room的多条件查询点击事件
	function getRoomByCondition(homeId){
		//序列化表单内容
		var formData = $("#roomForm").serialize();
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=getRoomByCondition&homeId="+homeId,
			type:"GET",
			data:formData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充信息函数
				fillRomeTableMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	};
	
	//根据房间编号删除房间信息
	function deleteRomeById(roomId){
		var homestayId = $("#roomIdLableHaveHomeId").data("homeid");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=deleteRomeById",
			type:"GET",
			data:{roomId:roomId,homestayId:homestayId},
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				console.log(result);
				//调用填充信息函数
				fillRomeTableMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	}
	
	//删除民宿的回调函数
	function deleteHomeById(homestayId){
		//获取当前页码值
		var pageNum  = $("#pageInfoTip").data("pagenum");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=deleteHomeById",
			type:"GET",
			data:{homestayId:homestayId,pageNum:pageNum,pageSize:"3"},
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				console.log(result);
				if("请先删除民宿下的房间"==result){
					alert(result);
				}else{
					//调用填充信息函数
					fillHomeTableMessage(result.data);
					//调用填充分页信息的函数
					fillPageMessage(result);
				}
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	}
	//对批量删除做点击事件
	function delAll(){
		//获取当前页码值
		var pageNum  = $("#pageInfoTip").data("pagenum");
		//定义一个存放被选中的对象id数组
		var arrayId=[];
		//获取页面上被选中的复选框对象
		$("input[name='delCheckbox']:checked").each(function(i){
			//把所有被选中的复选框的值存入数组
			arrayId[i]=$(this).val();
		});
		//拿到所有被选中的民宿id
		console.log(arrayId);
		//获取页面提示
		var tipMessage = $("#tipMessage").val();
		if(tipMessage==0){
			//等于0在民宿页面,发送民宿的ajax请求
			$.ajax({
				async:true,
				url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=deleteMoreHome",
				type:"GET",
				data:{idMessageArr:JSON.stringify(arrayId),pageNum:pageNum,pageSize:"3"},
				dataType:"json",//预期响应数据
				success:function(result,status,xhr){
					console.log(result);
					if("请先删除民宿下的房间"==result){
						alert(result);
					}else{
						//调用填充信息函数
						fillHomeTableMessage(result.data);
						//调用填充分页信息的函数
						fillPageMessage(result);
					}
				},
				//请求失败时的响应函数
				error:function(xhr,status,error){
					console.log("请求失败");
				}
			});
		}else if(tipMessage==1){
			//等于1在房间页面,获取当前民宿的民宿id
			var homestayId = $("#roomIdLableHaveHomeId").data("homeid");
			$.ajax({
				async:true,
				url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=deleteMoreRoom",
				type:"GET",
				data:{idMessageArr:JSON.stringify(arrayId),homestayId:homestayId},
				dataType:"json",//预期响应数据
				success:function(result,status,xhr){
					console.log(result);
						//调用填充信息函数
						fillRomeTableMessage(result);
				},
				//请求失败时的响应函数
				error:function(xhr,status,error){
					console.log("请求失败");
				}
			});
		}
	}
	
	//对返回上一级做点击事件
	function backParent(){
		//设置返回上一级按钮可见
		$("#backParent").css("display","none");
		//设置页面提示为1
		 $("#tipMessage").val("0");
		//获取页面提示信息
		var pageNum = $("#tipPageMessage").val();
		//获取页面条件
		var fromData =  $("#tipConditionMessage").val();
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=pageHomeMessage&pageNum="+pageNum+"&pageSize=3",
			type:"GET",
			data:fromData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				fillHomestayPageHead();
				//调用填充信息函数
				fillHomeTableMessage(result.data);
				//调用渲染分页信息函数
				fillPageMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	}
	 /*用户-添加弹出一个模态框*/
    function add(){
    	var tipMessage = $("#tipMessage").val();
    	if(tipMessage==0){
    		//如果等于0，则是在民宿页面
    		 $("#addHomeModal").css("display","block");
    		// $("#addHomeModal").css("width","500px");
    	}
    	if(tipMessage==1){
    	//如果等于1，则是在房间页面
   		 $("#addRoomModal").css("display","block");
    	//填充民宿id
    	$("#addRoomInHomeId").val($("#roomIdLableHaveHomeId").data("homeid"));
    	}
    }
	//对添加房间按钮做点击事件
	function addRoomFun(){
		//获取表单数据
		var formData = $("#addRoomForm").serialize(); 
		 $("#addRoomModal").css("display","none");
		 var homestayId = $("#roomIdLableHaveHomeId").data("homeid");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=addRoom&homestayId="+homestayId,
			type:"GET",
			data:formData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充信息函数
				fillRomeTableMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	} 
	
	//对添加民宿按钮做点击事件
	function addHomeFun(){
		//获取表单数据
		var formData = $("#addHomeForm").serialize(); 
		 $("#addHomeModal").css("display","none");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=addHome&pageNum=1&pageSize=3",
			type:"GET",
			data:formData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充民宿信息函数
				fillHomeTableMessage(result.data);
				//调用填充分页信息的函数
				fillPageMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	} 
	
	//对取消添加民宿做点击事件
	function cancelAddHome(){
		$("#addHomeModal").css("display","none");
	}
	
	//对取消添加房间做点击事件
	function cancelAddRoom(){
		$("#addRoomModal").css("display","none");
	}
	
	//对取消更新民宿做点击事件
	function cancelUpdataHome(){
		$("#updataHomeModal").css("display","none");
	}
	
	//对取消更新房间做点击事件
	function cancelUpdataRoom(){
		$("#updataRoomModal").css("display","none");
	}
	
	//对修改民宿信息作点击事件
	function updataHome(homeId,homeName,homeAddress,homePhone,homeIntroduce){
		$("#updataHomeModal").css("display","block");
		//填充民宿id
    	$("#updataHomeId").val(homeId);
    	//填充民宿名称
    	$("#updataHomeName").val(homeName);
    	//填充民宿地址
    	$("#updataHomeAddress").val(homeAddress);
    	//填充民宿电话
    	$("#updataHomePhone").val(homePhone);
    	//填充民宿介绍
    	$("#updataHomeIntroduce").val(homeIntroduce);
	}
	//对修改房间信息做点击事件
	function updateRomeMessageById(roomId,roomState,roomStyle,roomPrice){
		$("#updataRoomModal").css("display","block");
		//填充民宿id
    	$("#updataRoomId").val(roomId);
    	//填充民宿名称
    	$("#updataRoomState").val(roomState);
    	//填充民宿地址
    	$("#updataRoomPrice").val(roomPrice);
    	//填充民宿电话
    	$("#updataRoomInHomeId").val($("#roomIdLableHaveHomeId").data("homeid"));
    	//填充民宿介绍
    	$("#updataRoomStyle").val(roomStyle);
	}
	
	//对修改民宿按钮做点击事件
	function updataHomeFun(){
		//获取表单数据
		var formData = $("#updataHomeForm").serialize(); 
		 $("#updataHomeModal").css("display","none");
		 //获取当前页码
		 var pageNum  = $("#pageInfoTip").data("pagenum");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=addHome&pageNum="+pageNum+"&pageSize=3",
			type:"GET",
			data:formData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充民宿信息函数
				fillHomeTableMessage(result.data);
				//调用填充分页信息的函数
				fillPageMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	} 
	
	//对修改房间按钮做点击事件
	function updataRoomFun(){
		//获取表单数据
		var formData = $("#updataRoomForm").serialize(); 
		 $("#updataRoomModal").css("display","none");
		 var homestayId = $("#roomIdLableHaveHomeId").data("homeid");
		//发送ajax请求
		$.ajax({
			async:true,
			url:"${pageContext.request.contextPath}/HomestayMessageAdminServlet?op=updataRoom&homestayId="+homestayId,
			type:"GET",
			data:formData,
			dataType:"json",//预期响应数据
			success:function(result,status,xhr){
				//调用填充信息函数
				fillRomeTableMessage(result);
			},
			//请求失败时的响应函数
			error:function(xhr,status,error){
				console.log("请求失败");
			}
		});
	} 
	</script>
</head>
<body>
    <!-- 顶部开始 -->
    <div class="container">
        <div class="logo"><a href="./index.jsp">竹里馆</a></div>
        <div class="open-nav"><i class="iconfont">&#xe699;</i></div>
        <ul class="layui-nav right" lay-filter="">
          <li class="layui-nav-item">
             <a href="#">${sessionScope.adminMap.adminId}</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
              <dd><a href="#">退出</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item"><a href="${pageContext.request.contextPath}/back/index.jsp">首页</a></li>
        </ul>
    </div>
    <!-- 顶部结束 -->
    <!-- 中部开始 -->
    <div class="wrapper">
        <!-- 左侧菜单开始 -->
        <div class="left-nav">
          <div id="side-nav">
            <ul id="nav">
                <li class="list" current>
                    <a href="./index.jsp">
                        <i class="iconfont">&#xe761;</i>
                        首页
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                </li>              
                <li class="list" >
                    <a href="javascript:;">
                        <i class="iconfont">&#xe6a3;</i>
                                                  房源信息
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            <a href="./HomestayMessageAdmin.jsp">
                                <i class="iconfont">&#xe6a7;</i>
                                                      民宿管理
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="list" >
                    <a href="javascript:;">
                        <i class="iconfont">&#xe6a3;</i>
                        订单详情
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu" style="display:none">
                        <li>
                            <a href="./orderInfo.jsp">
                                <i class="iconfont">&#xe6a7;</i>
                                订单列表
                            </a>
                        </li>
                    </ul>
                </li>
                
                 
                <li class="list" >
                    <a href="javascript:;">
                        <i class="iconfont">&#xe6a3;</i>
                       	 销量统计
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu" style="display:none">
                        <li id="regionChart">
                            <a href="${pageContext.request.contextPath}/back/echarts.jsp">
                                <i class="iconfont">&#xe6a7;</i>
                              	 各地区总收入报表
                            </a>
                        </li>
                        <li id="styleChart">
                            <a href="${pageContext.request.contextPath}/back/echarts2.jsp">
                                <i class="iconfont">&#xe6a7;</i>
                                                                                               按风格查询报表                                                               
                            </a>
                        </li>
                    </ul>
                </li>
               
            </ul>
          </div>
        </div>
        <!-- 左侧菜单结束 -->
        <!-- 右侧主体开始 -->
        <div class="page-content">
          <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <div id="messagePageHead">
            </div>
             <xblock>
				<button class="layui-btn layui-btn-danger" onclick="delAll()">
					<i class="layui-icon">&#xe640;</i>批量删除
				</button>
				<button class="layui-btn" onclick="add()">
					<i class="layui-icon">&#xe608;</i>添加
				</button>
				<!-- value值为0代表在民宿页面，为1代表在房间页面 -->
				<input type="hidden" id="tipMessage" value="0">
				<input type="hidden" id="tipPageMessage" value="">
				<input type="hidden" id="tipConditionMessage" value="">
				<button class="layui-btn" style="display:none" id="backParent" onclick="backParent()">
					<i class="layui-icon">&#xe608;</i>返回上一级
				</button>
			</xblock>
				<table class="layui-table" id="tableMessage">
                </table>
                <div id="pageInfo"></div>
            <!-- 右侧内容框架，更改从这里结束 -->
          </div>
        </div>
        <!-- 右侧主体结束 -->
        <!-- 右侧主体结束 -->
    </div>
    <!-- 中部结束 -->
    <!-- 底部开始 -->
    <!-- 底部结束 -->
    <!-- 背景切换开始 -->
	<div class="bg-changer">
        <div class="swiper-container changer-list">
            <div class="swiper-wrapper">
                <div class="swiper-slide"><img class="item" src="./images/a.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/b.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/c.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/d.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/e.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/f.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/g.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/h.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/i.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/j.jpg" alt=""></div>
                <div class="swiper-slide"><img class="item" src="./images/k.jpg" alt=""></div>
                <div class="swiper-slide"><span class="reset">初始化</span></div>
            </div>
        </div>
        <div class="bg-out"></div>
        <div id="changer-set"><i class="iconfont">&#xe696;</i></div>   
    </div>
    <!-- 背景切换结束 -->
    	<!-- 添加 -->
	<div class="layui-layer layui-layer-iframe layer-anim"
		id="addHomeModal" style="display:none" type="iframe" times="2" showtime="0"
		contype="string"
		style="z-index: 19891016; width: 600px; height: 500px; top: 111px; left: 34px;">
		<div class="layui-layer-title" style="cursor: move;">添加用户</div>
		<div id="" class="layui-layer-content">
			<div class="content " >
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" id="addHomeForm">
            
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">民宿id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_email" name="addHomeId" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">名称</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_email" name="addHomeName" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">地址</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_email" name="addHomeAddress" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">介绍</span>
                    </label>
                    <div class="layui-input-inline">
                        <textarea id="L_email" name="addHomeIntroduce" autocomplete="off" class="layui-input" style="width:300px;height:100px"></textarea>
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">电话</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_email" name="addHomePhone" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">风格</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_email" name="addHomeStyle" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button  type="button" class="layui-btn" style="display:inline-block" onclick="addHomeFun()">添加</button>
                     <button type="button" class="layui-btn" style="display:inline-block" onclick="cancelAddHome()">取消</button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
          </div>
		</div>
		<span class="layui-layer-setwin"><a class="layui-layer-min"
			href="javascript:;"><cite></cite></a><a
			class="layui-layer-ico layui-layer-max" href="javascript:;"></a><a
			class="layui-layer-ico layui-layer-close layui-layer-close1"
			href="javascript:;"></a></span><span class="layui-layer-resize"></span>
	</div>
	<!-- 添加房间模态框 -->
    
    <div class="layui-layer layui-layer-iframe layer-anim"
		id="addRoomModal" style="display:none" type="iframe" times="2" showtime="0"
		contype="string"
		style="z-index: 19891016; width: 600px; height: 500px; top: 111px; left: 34px;">
		<div class="layui-layer-title" style="cursor: move;">添加房间</div>
		<div id="" class="layui-layer-content">
			 <div class="content" >
            <form class="layui-form" id="addRoomForm">
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">房间id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="addRoomId" name="addRoomId" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">状态</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="addRoomState" name="addRoomState" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">价格</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="addRoomPrice" name="addRoomPrice" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">民宿id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="addRoomInHomeId" name="addRoomInHomeId" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">风格</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="addRoomStyle" name="addRoomStyle" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="addRoomFun()">添加</button>
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="cancelAddRoom()">取消</button>
                </div>
            </form>
          </div> 
		</div>
		<span class="layui-layer-setwin"><a class="layui-layer-min"
			href="javascript:;"><cite></cite></a><a
			class="layui-layer-ico layui-layer-max" href="javascript:;"></a><a
			class="layui-layer-ico layui-layer-close layui-layer-close1"
			href="javascript:;"></a></span><span class="layui-layer-resize"></span>
	</div>
	
	<!-- 修改 -->
    <div class="layui-layer layui-layer-iframe layer-anim"
		id="updataHomeModal" style="display:none" type="iframe" times="2" showtime="0"
		contype="string"
		style="z-index: 19891016; width: 600px; height: 500px; top: 111px; left: 34px;">
		<div class="layui-layer-title" style="cursor: move;">修改民宿</div>
		<div id="" class="layui-layer-content">
			<div class="content " >
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" id="updataHomeForm">
            
                <div class="layui-form-item">
                    <label for="updataHomeId" class="layui-form-label">
                        <span class="x-red">民宿id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataHomeId" name="updataHomeId" autocomplete="off" class="layui-input" readonly="readonly">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="updataHomeName" class="layui-form-label">
                        <span class="x-red">名称</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataHomeName" name="updataHomeName" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="updataHomeAddress" class="layui-form-label">
                        <span class="x-red">地址</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataHomeAddress" name="updataHomeAddress" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="updataHomeIntroduce" class="layui-form-label">
                        <span class="x-red">介绍</span>
                    </label>
                    <div class="layui-input-inline">
                        <textarea id="updataHomeIntroduce" name="updataHomeIntroduce" autocomplete="off" class="layui-input" style="width:300px;height:100px"></textarea>
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="updataHomePhone" class="layui-form-label">
                        <span class="x-red">电话</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataHomePhone" name="updataHomePhone" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="updataHomeFun()">确认修改</button>
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="cancelUpdataHome()">取消</button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
          </div>
		</div>
		<span class="layui-layer-setwin"><a class="layui-layer-min"
			href="javascript:;"><cite></cite></a><a
			class="layui-layer-ico layui-layer-max" href="javascript:;"></a><a
			class="layui-layer-ico layui-layer-close layui-layer-close1"
			href="javascript:;"></a></span><span class="layui-layer-resize"></span>
	</div>
    
    <div class="layui-layer layui-layer-iframe layer-anim"
		id="updataRoomModal" style="display:none" type="iframe" times="2" showtime="0"
		contype="string"
		style="z-index: 19891016; width: 600px; height: 500px; top: 111px; left: 34px;">
		<div class="layui-layer-title" style="cursor: move;">修改房间</div>
		<div id="" class="layui-layer-content">
			 <div class="content" >
            <form class="layui-form" id="updataRoomForm">
                <div class="layui-form-item">
                    <label for="updataRoomId" class="layui-form-label">
                        <span class="x-red">房间id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataRoomId" name="updataRoomId" autocomplete="off" class="layui-input" readonly="readonly">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="updataRoomState" class="layui-form-label">
                        <span class="x-red">状态</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataRoomState" name="updataRoomState" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="updataRoomPrice" class="layui-form-label">
                        <span class="x-red">价格</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataRoomPrice" name="updataRoomPrice" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="updataRoomInHomeId" class="layui-form-label">
                        <span class="x-red">民宿id</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataRoomInHomeId" name="updataRoomInHomeId" autocomplete="off" class="layui-input" readonly="readonly">
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="updataRoomStyle" class="layui-form-label">
                        <span class="x-red">风格</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="updataRoomStyle" name="updataRoomStyle" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="updataRoomFun()">确认修改</button>
                    <button type="button" class="layui-btn" style="display:inline-block" onclick="cancelUpdataRoom()">取消</button>
                </div>
            </form>
          </div> 
		</div>
		<span class="layui-layer-setwin"><a class="layui-layer-min"
			href="javascript:;"><cite></cite></a><a
			class="layui-layer-ico layui-layer-max" href="javascript:;"></a><a
			class="layui-layer-ico layui-layer-close layui-layer-close1"
			href="javascript:;"></a></span><span class="layui-layer-resize"></span>
	</div>
    
    
</body>
</html>


















